function y=xicdfnew(xivals,alphbar,acost,bcost,scriptB)
%
% Compute CDF of fixed cost using the BEta dist. as the primitive dist.
%
% Input:
% 1. xivals: the specific cost
% 2. alphbar: the proportion of firms receiving zero cost
% 3. acost: a parameter for the Beta/Dotsey dist.
% 4. bcost: a parameter for the Beta/Dotsey dist.
% 5. scriptB: the largest fixed cost
%
%

xivals=min(xivals,scriptB);
xivals=max(xivals,0); 


%% BETA distribution

% % converted support for Beta dist.
% z = xivals/scriptB;
% 
% % the CDF of beta dist.
% Fbeta = betainc(z,acost,bcost);
% 
% % final cdf
% out = alphbar + (1-alphbar).*Fbeta;

%%


%% Dotsey distribution

z=xivals/scriptB;

minp=min([acost bcost]);
maxp=max([acost bcost]);

if (minp<=-pi/2)||(bcost>=pi/2)
    disp('inadmissable parameter values for dotsey distribution')
    disp('in call to xcidf.m')
end

K1=1/(tan(bcost)-tan(acost));
K2=-tan(acost)*K1;

x=z*bcost+(1-z)*acost;
y=K1*tan(x)+K2;

% modify underlying distribution F to produce adjusted distribution G
y=alphbar+(1-alphbar)*y;

%%






